package net.angrynut.web.configuration;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;

import net.angrynut.web.handler.interceptor.LogInterceptor;
import net.angrynut.web.model.converter.LoginFormToUserConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@SpringBootApplication(scanBasePackages = "net.angrynut.web")
@ServletComponentScan({ "net.angrynut.web.handler.servlet" })
public class WebBasicConfiguration extends WebMvcConfigurerAdapter {

	@Autowired
	private LogInterceptor logInterceptor;

	/**
	 * 这里配置 Spring MVC interceptor
	 */
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		registry.addInterceptor(logInterceptor);
	}

	@Override
	public void addFormatters(FormatterRegistry registry) {
		registry.addConverter(new LoginFormToUserConverter());
	}

}
